# Strum
[![Build Status](https://travis-ci.org/Peternator7/strum.svg?branch=master)](https://travis-ci.org/Peternator7/strum)
[![Latest Version](https://img.shields.io/crates/v/strum.svg)](https://crates.io/crates/strum)
[![Rust Documentation](https://docs.rs/strum/badge.svg)](https://docs.rs/strum)
Strum is a set of macros and traits for working with
enums and strings easier in Rust.
The full version of the README can be found on [Github](https://github.com/Peternator7/strum).
# Including Strum in Your Project
Import strum and strum_macros into your project by adding the following lines to your
Cargo.toml. Strum_macros contains the macros needed to derive all the traits in Strum.
```toml
[dependencies]
strum = "0.18.0"
strum_macros = "0.18.0"
```
And add these lines to the root of your project, either lib.rs or main.rs.
```rust
// Strum contains all the trait definitions
extern crate strum;
#[macro_use]
extern crate strum_macros;
# fn main() {}
```
# Strum Macros
Strum has implemented the following macros:
| Macro | Description |
| --- | ----------- |
| [EnumString] | Converts strings to enum variants based on their name |
| [Display] | Converts enum variants to strings |
| [AsRefStr] | Converts enum variants to `&'static str` |
| [IntoStaticStr] | Implements `From for &'static str` on an enum |
| [EnumVariantNames] | Implements Strum::VariantNames which adds an associated constant `VARIANTS` which is an array of discriminant names |
| [EnumIter] | Creates a new type that iterates of the variants of an enum. |
| [EnumProperty] | Add custom properties to enum variants. |
| [EnumMessage] | Add a verbose message to an enum variant. |
| [EnumDiscriminants] | Generate a new type with only the discriminant names. |
| [EnumCount] | Add a constant `usize` equal to the number of variants. |
[EnumString]: https://github.com/Peternator7/strum/wiki/Derive-EnumString
[Display]: https://github.com/Peternator7/strum/wiki/Derive-Display
[AsRefStr]: https://github.com/Peternator7/strum/wiki/Derive-AsRefStr
[IntoStaticStr]: https://github.com/Peternator7/strum/wiki/Derive-IntoStaticStr
[EnumVariantNames]: https://github.com/Peternator7/strum/wiki/Derive-EnumVariantNames
[EnumIter]: https://github.com/Peternator7/strum/wiki/Derive-EnumIter
[EnumProperty]: https://github.com/Peternator7/strum/wiki/Derive-EnumProperty
[EnumMessage]: https://github.com/Peternator7/strum/wiki/Derive-EnumMessage
[EnumDiscriminants]: https://github.com/Peternator7/strum/wiki/Derive-EnumDiscriminants
[EnumCount]: https://github.com/Peternator7/strum/wiki/Derive-EnumCount